home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5789 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  52 lines

  1. Path: newshost.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Easiest way to center a string?
  5. Date: 21 Feb 1996 04:07:46 GMT
  6. Organization: Los Alamos National Laboratory
  7. Message-ID: <TANMOY.96Feb20210746@qcd.lanl.gov>
  8. References: <4fobka$1st@parlor.hiwaay.net> <DMqEG5.8z4@eskimo.com>
  9.     <4frif5$e6p@fohnix.metronet.com> <DMuuzG.1yK@eskimo.com>
  10.     <4gbmmo$m5v@airdmhor.gen.nz> <4gdgs0$jg6@airdmhor.gen.nz>
  11. NNTP-Posting-Host: qcd.lanl.gov
  12. Mime-Version: 1.0
  13. Content-Type: text
  14. In-reply-to: gumboot@airdmhor.gen.nz's message of 21 Feb 1996 11:10:07 +1300
  15.  
  16. In article <4gdgs0$jg6@airdmhor.gen.nz> gumboot@airdmhor.gen.nz (Simon
  17. Hosie) writes: 
  18. <snip>
  19.    > printf("%*s\n", (strlen(String - LineLen) / 2, String);
  20.  
  21.      Sorry, make that:
  22.  
  23.    printf("%*s\n", (strlen(String + LineLen)) / 2, String);
  24.  
  25. Here is a program I tried:
  26.  
  27. #include <stdio.h>
  28. #include <string.h>
  29. int main(void) {
  30.  const char *String = "Hello";
  31.  int LineLen = 80;
  32.  printf("%*s\n", (strlen(String + LineLen)) / 2, String);
  33.  return 0;
  34. }
  35.  
  36. and here is what my compiler tells me:
  37.  
  38. junk.c: In function `main':
  39. junk.c:5: warning: field width is not type int (arg 2)
  40.  
  41. Can you figure out what happened?
  42.  
  43. Cheers
  44. Tanmoy
  45. --
  46. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  47. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  48. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  49. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  50. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  51. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  52.